//从vue-router这个依赖库中导入createRouter()函数, createWebHistory()函数
import {createRouter, createWebHistory} from "vue-router";
import {getTokenKey} from "../util/util.js";

//定义一个变量
let router = createRouter({
    //路由历史
    history: createWebHistory(),
    //配置路由，是一个数组，里面可以配置多个路由
    routes: [
        // 登录组件路由
        {
            path: '/', // 如果路由为/
            redirect: '/login' //重定向到登录组件
        },
        {
            path: '/login',
            component: () => import('../views/LoginView.vue'),
        },
        {
            path: '/dashboard',
            //路由路径所对应的页面
            component: () => import('../views/DashboardView.vue'),

            children: [
                {
                    path: '',
                    component: () => import('../views/StatisticsView.vue'),
                },
                {
                    path: 'user',
                    component: () => import('../views/UserView.vue'),
                },
                {
                    path: 'product',
                    component: () => import('../views/ProductView.vue'),
                },
                {
                    path: 'brand',
                    component: () => import('../views/BrandView.vue'),
                },
                {
                    path: 'upload',
                    component: () => import('../views/UploadView.vue'),
                },

                {
                    path: 'productType',
                    component: () => import('../views/ProductTypeView.vue'),
                },
                {
                    path: 'sales',
                    component: () => import('../views/SalesView.vue'),
                },
                {
                    path: 'orderProduct',
                    component: () => import('../views/OrderProductView.vue'),
                }, {
                    path: 'receivingAddress',
                    component: () => import('../views/ReceivingAddressView.vue'),
                },
                {
                    path: 'shopCart',
                    component: () => import('../views/ShopCartView.vue'),
                },
                {
                    path: 'shopCartProduct',
                    component: () => import('../views/ShopCartProductView.vue'),
                },

                {
                    path: 'carouselFigure',
                    component: () => import('../views/CarouselFigureView.vue'),
                },
                {
                    path: 'searchHistory',
                    component: () => import('../views/SearchHistoryView.vue'),
                },
                {
                    path: 'order',
                    component: () => import('../views/OrderView.vue'),
                }
            ]
        },
    ]
})
//导出创建的路由对象
export default router;